package com.kafka_demo.controller;

import com.kafka_demo.kafka.KafkaProducerManager;
import com.kafka_demo.pojo.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * kafka控制层
 *
 * @author : z_sz
 * @date : 2020-09-03 11:12
 **/
@RestController
@RequestMapping("/kafka")
public class KafkaController {

    /**
     * kafka生产者
     */
    @Autowired
    KafkaProducerManager kafkaProducerManager;


    @PostMapping("/send")
    public String sendMessage(@RequestBody Message message) {
        kafkaProducerManager.send(message.toString());
        return "ok";
    }
}
